from time import sleep

from wechat_test.page.base_page import BasePage


class OtherPage(BasePage):

    def External_inks(self):
        """
        外链用户播放
        :return:
        """
        self.start_app()
        self.poco(text='在线', name='com.tencent.mm:id/kbq').click()
        self.log_info('开始点击外链')
        self.poco(name='com.tencent.mm:id/bkl')[1].click()
        sleep(2)
        self.log_info('点击观看完整版')
        self.poco(name='android.view.View').click([0.9, 0.9])
        self.log_info('点击弹框打开按钮，唤起小程序')
        self.poco(text='打开').click()
        element = []
        text = self.poco(name='android.widget.TextView', type='android.widget.TextView')
        sleep(1)
        if len(text) > 0:
            for i in text:
                element.append(i.attr('text'))
        else:
            self.log_info(f'播放页元素没获取到：{element}')
        self.log_info(f'找播放页元素：{element}')
        return element
